home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // FILE: AEtransformRelated.mel
- // INPUT: string (node name)
- // RETURN: string[] (list of related nodes, with the node whose
- // tab you want to be opened duplicated at the
- // end of the array)
- //
-
-
- global proc int AEisLastNodeDuplicated(string $inputArray[])
- {
- int $inputArraySizeMinusOne = size($inputArray)-1;
- if ($inputArraySizeMinusOne < 1) return false;
- string $searchString = $inputArray[$inputArraySizeMinusOne];
- string $tmp[] = `ls -l $searchString`;
- $searchString = $tmp[0];
- for ($i = 0; $i < $inputArraySizeMinusOne; $i++) {
- clear $tmp;
- $tmp = `ls -l $inputArray[$i]`;
- if ( $searchString == $tmp[0]) return true;
- }
- return false;
- }
-
-
- global proc string[] AEtransformRelated (string $nodeName)
- {
- string $retval[];
- string $preferredNode = "";
-
- // get all shapes immediately below the transform first
- //
- string $leaves[] = `listRelatives -fullPath -shapes $nodeName`;
- for ($leaf in $leaves) {
- $retval[size($retval)] = $leaf;
- }
-
- // now get the connections for the transform
- // to deal with things like expressions, motionPaths, etc.
- //
- string $tmp[];
- $tmp = `defaultNavigation -ren -d $nodeName`;
- for ($node in $tmp) {
- $retval[size($retval)] = $node;
- }
-
- // loop through each of the leaves looking for
- // appropriate AE<leafType>Related.mel scripts
- //
- for ($leaf in $leaves) {
-
- clear $tmp;
- // get the leaf's nodeType
- string $leafType = `nodeType $leaf`;
-
- // build the related script's name
- string $relatedScript = "AE"+$leafType+"Related";
-
- if (`exists $relatedScript`) {
-
- // if an AE*Related script exists for the shape leaf
- // node, run it
- //
- $tmp = eval($relatedScript+" \""+$leaf+"\"");
-
- // Check if the last item is duplicated.
- // AEisLastNodeDuplicated is a Mel script which will
- // search the input string array for a duplicate
- // occurrence of the last element in that array.
- // AEisLastNodeDuplicated returns 1 if true, 0 if false.
- // (this script is shown below)
- //
- // Note that any node that has been designated "internal"
- // is not a candidate for preferred status.
- //
- if (AEisLastNodeDuplicated($tmp) == true) {
- string $pNode = $tmp[size($tmp)-1];
- if ( !`attributeQuery -ex -node $pNode intermediateObject` ||
- !`getAttr ($pNode+".intermediateObject")` ){
- $preferredNode = $pNode;
- }
- }
-
- } else {
-
- $tmp = `defaultNavigation -ren -d $leaf`;
- string $tmpPreferredNode = `defaultNavigation -dwn -d $leaf`;
- string $tmpPreferredFullPathName[] = `ls -l $tmpPreferredNode`;
- if ( $tmpPreferredFullPathName[0] != $leaf
- || $preferredNode == "" )
- {
- $preferredNode = $tmpPreferredNode;
- $tmp[size($tmp)] = $preferredNode;
- }
-
- }
-
- // catenate the result to the return string array ($retval)
- for ($i = 0; $i < size($tmp); $i++) {
- $retval[size($retval)] = $tmp[$i];
- }
-
- }
-
- // Note that if you have multiple leaves and each specifies
- // a preferredNode, only the last one is remembered.
- // If no preferredNode was specified, the transform itself
- // is used.
- //
- if ($preferredNode == "") {
- $retval[size($retval)] = $nodeName;
- } else {
- $retval[size($retval)] = $preferredNode;
- }
-
- return $retval;
- }
-
-